package org.fyp.synchrona.blog.service;

import org.apache.log4j.Logger;
import org.fyp.synchrona.blog.service.util.NewData;
import org.fyp.synchrona.blog.service.util.OldData;
import org.fyp.synchrona.core.info.impl.ICommonDataObject;


public class NewDataProcessor{
	
	public NewData newDataObj;
	
	public OldData oldDataObj;
	
	static final Logger logger = Logger.getLogger(NewDataProcessor.class);
	
	public NewDataProcessor(OldData oldDataObj, NewData newDataObj) {
		this.newDataObj = newDataObj;
		this.oldDataObj = oldDataObj;
	}
	public void createUpdateObj(ICommonDataObject cpo) {
		newDataObj.setSecurity_Token(oldDataObj.getSecurity_Token());
		newDataObj.setSecurityToken(oldDataObj.getSecurityToken());
		newDataObj.setEnable("true");
		newDataObj.setShowname("true");
		newDataObj.setShowemail("true");
		/* email */
		if(cpo.getEMAIL()!=null){
			newDataObj.setEmail(cpo.getEMAIL());
		}else{
			newDataObj.setEmail(oldDataObj.getEmail());
		}
		/* display name */
		if(cpo.getUSER_NAME()!=null){
			newDataObj.setWidget_displayname(cpo.getUSER_NAME());
		}else{
			newDataObj.setWidget_displayname(oldDataObj.getWidget_displayname());
		}
		/* first name */
		if(cpo.getFIRST_NAME()!=null){
			newDataObj.setFirstName(cpo.getFIRST_NAME());
		}else{
			newDataObj.setFirstName(oldDataObj.getFirstName());
		}
		/*last name*/
		if(cpo.getLAST_NAME()!=null){
			newDataObj.setLastName(cpo.getLAST_NAME());
		}else{
			newDataObj.setLastName(oldDataObj.getLastName());
		}
		/*photourl*/
		if(cpo.getPHOTO_URL()!=null){
			newDataObj.setPhotourl(cpo.getPHOTO_URL());
		}else{
			newDataObj.setPhotourl(oldDataObj.getPhotourl());
		}
		/*photowidth*/
		if(cpo.getPHOTO_WIDTH()!=null){
			newDataObj.setPhotowidth(cpo.getPHOTO_WIDTH());
		}else{
			newDataObj.setPhotowidth(oldDataObj.getPhotowidth());
		}
		/*photoheight*/
		if(cpo.getPHOTO_HEIGHT()!=null){
			newDataObj.setPhotoheight(cpo.getPHOTO_HEIGHT());
		}else{
			newDataObj.setPhotoheight(oldDataObj.getPhotoheight());
		}
		/*image file name*/
		newDataObj.setImageFileName(oldDataObj.getImageFileName());
		/*usi radio*/
		newDataObj.setUSIradio(oldDataObj.getUSIradio());
		/*usi error*/
		newDataObj.setUSIError(oldDataObj.getUSIError());
		/*audioclip*/
		newDataObj.setAudioclipurl(oldDataObj.getAudioclipurl());
		/*gender*/
		if(cpo.getSEX()!=null){
			newDataObj.setGender(cpo.getSEX());
		}else{
			newDataObj.setGender(oldDataObj.getGender());
		}
		/*birthmonth*/
		if(cpo.getBIRTH_MONTH()!=null){
			newDataObj.setBirthmonth(cpo.getBIRTH_MONTH());
		}else{
			newDataObj.setBirthmonth(oldDataObj.getBirthmonth());
		}
		/*birthday*/
		if(cpo.getBIRTH_DAY()!=null){
			newDataObj.setBirthday(cpo.getBIRTH_DAY());
		}else{
			newDataObj.setBirthday(oldDataObj.getBirthday());
		}
		/*birthyear*/
		if(cpo.getBIRTH_YEAR()!=null){
			newDataObj.setBirthyear(cpo.getBIRTH_YEAR());
		}else{
			newDataObj.setBirthyear(oldDataObj.getBirthyear());
		}
		/*astrologicalsighns*/
		newDataObj.setShowAstrologicalSigns(oldDataObj.getShowAstrologicalSigns());
		/*url*/
		if(cpo.getWEBSITE()!=null){
			newDataObj.setUrl(cpo.getWEBSITE());			
		}else{
			newDataObj.setUrl(oldDataObj.getUrl());
		}
		/*wishlisturl*/
		newDataObj.setWishlisturl(oldDataObj.getWishlisturl());
		/*imusername*/
		newDataObj.setImusername(oldDataObj.getImusername());
		/*imnetwor*/
		newDataObj.setImnetwork(oldDataObj.getImnetwork());
		/*city*/
		if(cpo.getCITY()!=null){
			newDataObj.setWidget_city(cpo.getCITY());
		}else{
			newDataObj.setWidget_city(oldDataObj.getWidget_city());
		}
		/*state*/
		if(cpo.getCOUNTRY_CITY()!=null){
			newDataObj.setWidget_state(cpo.getCOUNTRY_CITY());
		}else{
			newDataObj.setWidget_state(oldDataObj.getWidget_state());
		}
		/*country*/
		if(cpo.getCOUNTRY()!=null){
			newDataObj.setWidget_country(cpo.getCOUNTRY());
		}else{
			newDataObj.setWidget_country(oldDataObj.getWidget_country());
		}
		/*ind*/
		newDataObj.setInd(oldDataObj.getInd());
		/*occupation*/
		newDataObj.setOccupation(oldDataObj.getOccupation());
		/*interests*/
		newDataObj.setInterests(oldDataObj.getInterests());
		/*aboutme*/
		if(cpo.getBIO()!=null){
			logger.info("[BLOGGER new bio ::]"+cpo.getBIO());
			newDataObj.setWidget_aboutme(cpo.getBIO());
		}else{
			logger.info("[BLOGGER new bio ::]"+oldDataObj.getWidget_aboutme());
			newDataObj.setWidget_aboutme(oldDataObj.getWidget_aboutme());
		}

		newDataObj.setMovies(oldDataObj.getMovies());
		newDataObj.setMusic(oldDataObj.getMusic());
		newDataObj.setBooks(oldDataObj.getBooks());
		newDataObj.setWackyQuestion(oldDataObj.getWackyQuestion());
		newDataObj.setWackyAnswer(oldDataObj.getWackyAnswer());
		newDataObj.setSubmitButton(oldDataObj.getSubmitButton());
	}



	

	
	
	
	
	

}
